package cn.pconline.autoclub.entity;

import java.util.Date;

import org.gelivable.dao.Column;
import org.gelivable.dao.Entity;
import org.gelivable.dao.Id;
import org.gelivable.dao.Transient;


import cn.pconline.autoclub.util.EncodeUtils;

import com.alibaba.fastjson.JSONObject;

/** 
 * @author 作者 guoqiang
 * @version 2014-1-21 活动人员
 */
@Entity(tableName = "ac_activity_member")
public class ActivityMember {
	
	public static final int STATUS_APPLY = 0;  //申请加入活动
	public static final int STATUS_PASS = 1;  //加入活动审核通过
	public static final int STATUS_DELETE = -1;//删除状态
	public static final int STATUS_OTHER = 99;//其他状态
    public static final int STATUS_REFUSE = 2;  //拒绝参加活动
	
	public static final int ISDRIVING_YES = 1;//自驾车
	public static final int ISDRIVING_NO = 0;//不自驾车
	/**
	 * 活动人员ID
	 */
	@Id
    @Column(name = "id")
	private long id;

	/**
	 * 活动ID
	 */
	@Column(name = "activity_id")
	private long activityId;
	/**
	 * 用户ID
	 */
	@Column(name = "user_id")
	private long userId;
	/**
	 * 姓名
	 */
	@Column(name = "name")
	private String name;
	/**
	 * 联系电话
	 */
	@Column(name = "phone")
	private String phone;
	/**
	 * 参加人数
	 */
	@Column(name = "join_num")
	private int joinNum;
	/**
	 * 车牌
	 */
	@Column(name = "license_plate")
	private String lincensePlate;
	/**
	 * 备注
	 */
	@Column(name = "descript")
	private String descript;
	/**
	 * 创建时间
	 */
	@Column(name = "create_at")
	private Date createAt;
	/**
	 * 用户昵称
	 */
	@Column(name = "nikename")
	private String nikename;
	
	/**
	 * 报名状态
	 * @return
	 */
	@Column(name = "status")
	private int status;
	
	/**
	 * 是否驾车
	 * @return
	 */
	@Column(name = "is_driving")
	private int isDriving;
	
	/**
	 * 头像地址
	 * @return
	 */
	@Transient(cache = false)
	private String userPic;
	/**
	 * 个人中心地址
	 * @return
	 */
	@Transient(cache = false)
	private String userUrl;
	
	/**
	 * 个人中心wap地址
	 * @return
	 */
	@Transient(cache = false)
	private String userWapUrl;
	
	/**
	 * 用户信息映射
	 */
	@Transient(cache = false)
    private User user;

	public int getIsDriving() {
		return isDriving;
	}

	public void setIsDriving(int isDriving) {
		this.isDriving = isDriving;
	}

	public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String getUserWapUrl() {
        return userWapUrl;
    }

    public void setUserWapUrl(String userWapUrl) {
        this.userWapUrl = userWapUrl;
    }

    public String getUserPic() {
        return userPic;
    }

    public void setUserPic(String userPic) {
        this.userPic = userPic;
    }

    public String getUserUrl() {
        return userUrl;
    }

    public void setUserUrl(String userUrl) {
        this.userUrl = userUrl;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getActivityId() {
        return activityId;
    }

    public void setActivityId(long activityId) {
        this.activityId = activityId;
    }

    /**
     * !!!!虽然叫user_id但实际存的是mebmer_id！！！！！
     *
     * @return
     */
    public long getUserId() {
        return userId;
    }

    /**
     * !!!!虽然叫user_id但实际存的是mebmer_id！！！！！
     *
     * @param userId
     */
    public void setUserId(long userId) {
        this.userId = userId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public int getJoinNum() {
        return joinNum;
    }

    public void setJoinNum(int joinNum) {
        this.joinNum = joinNum;
    }

    public String getLincensePlate() {
        return lincensePlate;
    }

    public void setLincensePlate(String lincensePlate) {
        this.lincensePlate = lincensePlate;
    }

    public String getDescript() {
        return descript;
    }

    public void setDescript(String descript) {
        this.descript = descript;
    }

    public Date getCreateAt() {
        return createAt;
    }

    public void setCreateAt(Date createAt) {
        this.createAt = createAt;
    }

    public String getNikename() {
        return nikename;
    }

    public void setNikename(String nikename) {
        this.nikename = nikename;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }
	
	 public JSONObject toJson(){
	        JSONObject jsonObject = new JSONObject();
	        jsonObject.put("userName", getName());
        	jsonObject.put("nickName", getNikename());
        	jsonObject.put("joinNum", getJoinNum());
        	jsonObject.put("phone", getPhone());
        	jsonObject.put("descript", getDescript());
        	jsonObject.put("lincensePlate", getLincensePlate());
        	jsonObject.put("memberId", getUserId());
        	jsonObject.put("isDriving", getIsDriving());
	                 
	        return jsonObject;        
	  }    
	    
	  public JSONObject toJsonEncodeHTML(){
	        JSONObject jsonObject = toJson();        
	        jsonObject.put("userName", EncodeUtils.encodeForHTMLFilterNull(getName()));
        	jsonObject.put("nickName", EncodeUtils.encodeForHTMLFilterNull(getNikename()));
        	jsonObject.put("descript", EncodeUtils.encodeForHTMLFilterNull(getDescript()));
        	jsonObject.put("lincensePlate", EncodeUtils.encodeForHTMLFilterNull(getLincensePlate()));
	        return jsonObject;
	    }  
}
